< previous page page_141 next page >

Page 141
The LBound() function will return to you the lower boundary of the array. This is typically set to 0 unless youve used the Option Base statement or youve declared the array with the To option.
The UBound() function will return to you the upper boundary of the array. For example, if you declare the array
9f31265bb40b592b1929e18a47ab28e5.gif
Dim astrNames(10) As String
the LBound() function will return 0 and the UBound() function will return 10.
Clearing an Array
The Erase command in Visual Basic clears out the contents of any array. If you erase a fixed-size array, all the elements in the array will be reinitialized to the default value for that data type. If you erase a dynamic array, the complete array will be released from memory. You then need to redimension the dynamic array back to a new size before you could use it again.
9f31265bb40b592b1929e18a47ab28e5.gif
Erase astrNames
Multidimensional Arrays
A multidimensional array is an array that has more than one dimension to it. The most common multidimensional array youll use is a two-dimensional array. This is like a table with rows and columns. Think of an Excel spreadsheetthis is an excellent example of a two-dimensional array. Visual Basic allows you to create up to 60 dimensions in a array. To create a multidimensional array, you simply specify an index number for each dimension want to create. Heres a typical two-dimensional array declaration:
9f31265bb40b592b1929e18a47ab28e5.gif
Dim avntEmployees(3, 2) As Variant
This example creates four rows and three columns for the array. Remember the previous example that created three different arraysone for the SSN, one for the name, and one for the salary? Well, with a two-dimensional array, you can combine all of those arrays into one. Lets look at this array to see how you might use it.

 
< previous page page_141 next page >

If you like this book, buy it!